Nova Cloud System 架設實例
opensatck Nova 手動安裝實例安裝 第一篇 建立nova 系統 控制中心 Nova 也被稱為 OpenStack Compute , 是一套用開源控制基礎架構Iaas 的雲端運算平台軟體。它的架構與功能類似Amazon EC2 與 Rackspace Cloud Servers. Nova本身是不包含虛擬化軟體，它是定義了一個驅動既有底層虛擬化作業系統的機制，並且將功能擴展為透過web API來進行操作。如圖一所示 API Server 透過Openstack API 與EC2 API 來管理所有的Hypervisor 機制 圖一 Openstack Nova (模式:單一控制台與多個節點 )繁體中文 安裝紀錄 nova安裝硬體條件 一 環境要求 1.至少需要兩部安裝nova-compute 的電腦，並且CPU必須支援Virtualization。 欲查看電腦的cpu是否支援Virtualization可以打 egrep -c '(vmx|svm)' /proc/cpuinfo 檢查cpu是否支援虛擬化,如果算出來的數字大於 0 的話，就表示有支援了，不過還是記得要去 BIOS 裡確認是否有 Enable CPU Virtualization 的功能上 AMD 的官方網站查詢CPU是否支援 http://www.amd.com/TW/PRODUCTS/Pages/Products.aspx 上 Intel 的官方網頁查詢CPU是否支援 http://processorfinder.intel.com/Default.aspx 2. 網路需求 A.網路環境要求每台電腦配裝雙網卡(最好能上 GIGALAN ) B.需要網路環境有兩台一般Switch或者 Hub C.需要有兩個區段的網段,且兩部機器的外部網路(public),與內部網路(LAN)必須個別的可找到對方使用ping 指令能有回應 3.Linux版本:ubuntu 11.04 Server LTS 4.硬碟空間則須看你把openstack nova 的分成幾個元件安裝,我們的例子是裝一台All in one的 ---- 二 網路拓璞架構圖 圖二 電腦 eth0 eth1 Nova-CC 0.0.0.0/24 172.18.104.11/24 Nova-1 0.0.0.0/24 172.18.104.12/24 Hub1(nova內部溝通) Nova-CC ↔ HUB port Nova-1 ↔HUB port Hub2(必須連至外部) Nova-CC ↔HUB port Nova-1 ↔HUB port 若以此圖將網路環境設好後請利用ping指令測試兩台電腦的兩個網段是否可以互相連接成功 三:安裝 nova-controler Setp-1 更新 安裝之前先進行更新 sudo apt-get update ;sudo apt-get upgrade Setp-2 設定安裝網路環境 目標:安裝 bridge 指令: sudo apt-get install bridge-utils 檢查 :dpkg -l | grep bridge-utils 成功結果 :ii bridge-utils 1.4-5ubuntu2 Utilities for configuring the Linux Ethernet bridge 錯誤狀況/故障排除: 網路可能不通 或者 apt-get 因網路環境無法更新 指令: sudo vi /etc/network/interfaces 編輯ok 重啟 sudo /etc/init.d/networking restart auto lo iface lo inet loopback auto br100 iface br100 inet static bridge_ports eth1 bridge_stp off bridge_maxwait 0 bridge_fd 0 address 192.168.0.1 netmask 255.255.255.0 auto eth0 iface eth0 inet static address 172.18.104.11 netmask 255.255.255.0 broadcast 172.18.104.255 gateway 172.18.104.254 dns-nameservers 61.64.127.1 檢查 :ifconfig 成功結果 : br100 Link encap:Ethernet HWaddr 00:21:5e:01:02:33 inet addr:192.168.0.1 Bcast:192.168.0.255 Mask:255.255.255.0 inet6 addr: fe80::221:5eff:fe01:233/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:189 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 B) TX bytes:18749 (18.7 KB) eth0 Link encap:Ethernet HWaddr 00:10:18:1a:48:13 inet addr:172.18.104.11 Bcast:172.18.104.255 Mask:255.255.255.0 inet6 addr: fe80::210:18ff:fe1a:4813/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:6470 errors:0 dropped:0 overruns:0 frame:0 TX packets:473 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:690979 (690.9 KB) TX bytes:108272 (108.2 KB) Interrupt:16 eth1 Link encap:Ethernet HWaddr 00:21:5e:01:02:33 inet6 addr: fe80::221:5eff:fe01:233/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:98 errors:0 dropped:0 overruns:0 frame:0 TX packets:148 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:8820 (8.8 KB) TX bytes:17781 (17.7 KB) Interrupt:17 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:4 errors:0 dropped:0 overruns:0 frame:0 TX packets:4 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:240 (240.0 B) TX bytes:240 (240.0 B) 錯誤狀況/故障排除: 失敗 networking 是無法 restart 大概就是編輯錯誤 Setp-3 安裝NTP Server Nova的各個所有組件的OpenStack要同步。 我們需要運做 NTPServer將每個組件同步時間 指令: sudo apt-get install ntp 檢查 :dpkg -l | grep ntp 成功結果 : ii ntp 1:4.2.6.p2+dfsg-1ubuntu5.1 Network Time Protocol daemon and utility programs ii ntpdate 1:4.2.6.p2+dfsg-1ubuntu5.1 client for setting system time from NTP servers 錯誤狀況/故障排除:網路可能不通 或者 apt-get 因網路環境無法更新 安裝完成後接著我們必須編輯sudo vi /etc/ntp.conf 將底下這兩行加入後存檔 server 127.127.1.0 fudge 127.127.1.0 stratum 10 然後我們將 NTP Server 重新啟動 sudo /etc/init.d/ntp restart * Stopping NTP server ntpd [ OK ] * Starting NTP server ntpd [ OK ] Setp-4 安裝mysql-server 設定nova需要的資料庫環境 OpenStack Nova提供兩種Database PostgreSQL or MySQL 我們選擇以MySQL進行 目標:安裝 mysql-server 指令: sudo apt-get install -y mysql-server 接著我們會看到安裝的過程會需要設MySQL 的password 且需要輸入兩次一樣密碼按 ok,請設定一組密碼並將該密碼記住 檢查 :dpkg -l | grep mysql-server 成功結果 : ii mysql-server 5.1.54-1ubuntu4 MySQL database server (metapackage depending on the latest version) ii mysql-server-5.1 5.1.54-1ubuntu4 MySQL database server binaries and system database setup ii mysql-server-core-5.1 5.1.54-1ubuntu4 MySQL database server binaries 錯誤狀況/故障排除: 網路可能不通 或者 apt-get 因網路環境無法更新 安裝完成後必須在將nova的資料庫環境設定完成請一以下步驟完成,我們以較簡單 5.個步驟完成方式 將底下的$MYSQL_PASS 都改成 剛剛所設定的MySql密碼,例如都設成novapasswd 1.sudo mysql -uroot -p$MYSQL_PASS -e 'CREATE DATABASE nova;' 2.sudo mysql -uroot -p$MYSQL_PASS -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;" 3.sudo mysql -uroot -p$MYSQL_PASS -e "SET PASSWORD FOR 'root'@'%' = PASSWORD('$MYSQL_PASS');" 1.sudo mysql -uroot -pnovapasswd-e 'CREATE DATABASE nova;' 2.sudo mysql -uroot -pnovapasswd -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;" 3.sudo mysql -uroot -pnovapasswd -e "SET PASSWORD FOR 'root'@'%' = PASSWORD('novapasswd');" 4.sudo sed -i 's/127.0.0.1/0.0.0.0/g' /etc/mysql/my.cnf ; sudo service mysql restart mysql start/running, process 22072 5.接著我們安裝 phpmysql sudo apt-get -y install apache2 php5 libapache2-mod-auth-mysql php5-mysql phpmyadmin 安裝過程中出現下圖時請選擇 apache2 再按ok 來方便以後查詢nova database狀態,安裝過程一樣需要輸入密碼,請輸入 mysql root 密碼 這個例子中我們輸入novapasswd 我們可以輸入網址 http:// nova-cc ip/phpmyadmin/ 來查看與管理資料庫 Setp-5 安裝Nova-Volumes 先將硬碟分割完成 fdisk /dev/sda 我們先把空間分出一區做Linux LVM partprobe fdisk -l Device Boot Start End Blocks Id System /dev/sda1 * 1 2432 19530752 83 Linux /dev/sda2 2432 3428 8000512 82 Linux swap / Solaris /dev/sda4 3428 9729 50615904+ 5 Extended /dev/sda5 3428 9729 50615873 8e Linux LVM pvcreate /dev/sda5 Physical volume "/dev/sda5" successfully created vgcreate nova-volumes /dev/sda5 Volume group "nova-volumes" successfully created service iscsitarget start service nova-volume start Setp-6 安裝nova 元件 目標:安裝 Nova Components 指令: sudo apt-get install -y rabbitmq-server nova-common nova-doc python-nova nova-api nova-network nova-volume nova-objectstore nova-scheduler nova-compute apt-get install glance 檢查 :dpkg -l | grep rabbitmq-server; dpkg -l | grep nova-common;dpkg -l | grep nova-doc; dpkg -l | grep python-nova ; dpkg -l | grep nova-api; dpkg -l | grep nova-network; dpkg -l | grep nova-volume; dpkg -l | grep nova-objectstore; dpkg -l | grep nova-scheduler; dpkg -l | grep nova-compute ; dpkg -l | grep euca2ools ; dpkg -l |grep unzip; dpkg -l | grep bridge-utils 成功結果 : ii rabbitmq-server 2.3.1-1ubuntu1 An AMQP server written in Erlang ii nova-common 2011.2-0ubuntu1 OpenStack Compute - Nova - common files ii nova-doc 2011.2-0ubuntu1 OpenStack Compute - Nova - documetation ii python-nova 2011.2-0ubuntu1 OpenStack Compute - Nova - Python libraries ii python-novaclient 2.4-0ubuntu1 client library for OpenStack Compute API ii nova-api 2011.2-0ubuntu1 OpenStack Compute - Nova - API frontend ii nova-network 2011.2-0ubuntu1 OpenStack Compute - Nova - Network thingamajig ii nova-volume 2011.2-0ubuntu1 OpenStack Compute - Nova - storage ii nova-objectstore 2011.2-0ubuntu1 OpenStack Compute - Nova - object store ii nova-scheduler 2011.2-0ubuntu1 OpenStack Compute - Nova - Scheduler ii nova-compute 2011.2-0ubuntu1 OpenStack Compute - Nova - compute node ii euca2ools 1.3.1-0ubuntu7 managing cloud instances for Eucalyptus ii unzip 6.0-4ubuntu1 De-archiver for .zip files ii glance 2011.2-0ubuntu1 OpenStack Image Registry and Delivery Service - Daemons ii python-glance 2011.2-0ubuntu1 OpenStack Image Registry and Delivery Service - Python library 錯誤狀況/故障排除: 網路可能不通 或者 apt-get 因網路環境無法更新 設定nova 環境 sudo nano /etc/nova/nova.conf --dhcpbridge_flagfile=/etc/nova/nova.conf --dhcpbridge=/usr/bin/nova-dhcpbridge --logdir=/var/log/nova --state_path=/var/lib/nova --lock_path=/var/lock/nova --verbose --s3_host=172.18.104.11 ###外部ip --rabbit_host=192.168.0.1 ###內部ip --cc_host=192.168.0.1 ###內部ip --ec2_url=http://172.18.104.11:8773/services/Cloud ###外部ip --fixed_range=10.0.0.0/8 --network_size=256 --FAKE_subdomain=ec2 --routing_source_ip=192.168.0.1 ###內部ip --sql_connection=mysql://root:nova@172.18.104.11/nova ###外部ip 需要mysql帳號:密碼 --glance_host=192.168.0.1 ###內部ip --image_service=nova.image.glance.GlanceImageService --iscsi_ip_prefix=192.168.0. ---- 接著設定好後需要建立 1.sudo sed -i 's/false/true/g' /etc/default/iscsitarget ; sudo service iscsitarget restart * Removing iSCSI enterprise target devices: [ OK ] * Stopping iSCSI enterprise target service: [ OK ] * Removing iSCSI enterprise target modules: [ OK ] * Starting iSCSI enterprise target service [ OK ] [ OK ] 2.指令: sudo groupadd nova ; chmod 644 /etc/nova/nova.conf 檢查 :ls -la /etc/nova/nova.conf 成功結果 :-rw-r--r-- 1 root nova 544 2011-08-06 01:15 /etc/nova/nova.conf 3.指令: sudo /etc/init.d/libvirt-bin start; sudo start nova-network; sudo start nova-compute; sudo start nova-api; sudo start nova-objectstore; sudo start nova-scheduler; sudo start nova-volume; sudo start glance-api; sudo start glance-registry 成功結果 : Since the script you are attempting to invoke has been converted to an Upstart job, you may also use the start(8) utility, e.g. start libvirt-bin start: Job is already running: nova-network start: Job is already running: nova-compute start: Job is already running: nova-api start: Job is already running: nova-objectstore start: Job is already running: nova-scheduler nova-volume start/running, process 21386 start: Job is already running: glance-api start: Job is already running: glance-registry 4. sudo nova-manage db sync sudo nova-manage user admin nova export EC2_ACCESS_KEY=7f29fa0c-7ad1-4c4f-9105-3637daa9cd6d export EC2_SECRET_KEY=4617cac1-6851-47e8-9c2f-1aef37f1bcef sudo nova-manage project create mycloud nova nova-manage network create 192.168.0.0/24 1 256 mkdir -p /home/nova/creds sudo nova-manage project zipfile mycloud nova /home/nova/creds/novacreds.zip unzip /home/nova/creds/novacreds.zip -d /home/nova/creds/ Archive: /home/nova/creds/novacreds.zip extracting: /home/nova/creds/novarc extracting: /home/nova/creds/pk.pem extracting: /home/nova/creds/cert.pem extracting: /home/nova/creds/cacert.pem root@nova-cc:~# sudo chown -R nova:nova /home/nova/creds/ root@nova-cc:~# ls -la /home/nova/creds/ total 32 drwxr-xr-x 2 nova nova 4096 2011-08-06 03:15 . drwxr-xr-x 3 root root 4096 2011-08-06 03:10 .. -rw------- 1 nova nova 1029 2011-08-06 03:11 cacert.pem -rw------- 1 nova nova 2503 2011-08-06 03:11 cert.pem -rw-r--r-- 1 nova nova 5786 2011-08-06 03:11 novacreds.zip -rw------- 1 nova nova 981 2011-08-06 03:11 novarc -rw------- 1 nova nova 887 2011-08-06 03:11 pk.pem source /home/nova/creds/novarc sudo /etc/init.d/libvirt-bin restart; sudo restart nova-network; sudo restart nova-compute; sudo restart nova-api; sudo restart nova-objectstore; sudo restart nova-scheduler; sudo restart nova-volume; sudo restart glance-api; sudo restart glance-registry Since the script you are attempting to invoke has been converted to an Upstart job, you may also use the stop(8) and then start(8) utilities, e.g. stop libvirt-bin ; start libvirt-bin. The restart(8) utility is also available. libvirt-bin stop/waiting libvirt-bin start/running, process 23598 nova-network start/running, process 23620 nova-compute start/running, process 23648 nova-api start/running, process 23663 nova-objectstore start/running, process 23674 nova-scheduler start/running, process 23699 nova-volume start/running, process 23708 glance-api start/running, process 23715 glance-registry start/running, process 23732 root@nova-cc:~# euca-describe-availability-zones verbose AVAILABILITYZONE nova available AVAILABILITYZONE |- nova-cc AVAILABILITYZONE | |- nova-compute enabled :-) 2011-08-06 08:15:15 AVAILABILITYZONE | |- nova-scheduler enabled :-) 2011-08-06 08:15:13 AVAILABILITYZONE | |- nova-network enabled :-) 2011-08-06 08:15:13 AVAILABILITYZONE | |- nova-volume enabled :-) 2011-08-06 08:15:13 Nova Dashboard 安裝 sudo apt-get install -y bzr sudo easy_install virtualenv Searching for virtualenv Reading http://pypi.python.org/simple/virtualenv/ Reading http://virtualenv.openplans.org Reading http://www.virtualenv.org Best match: virtualenv 1.6.4 Downloading http://pypi.python.org/packages/source/v/virtualenv/virtualenv- 1.6.4.tar.gz#md5=1072b66d53c24e019a8f1304ac9d9fc5 Processing virtualenv-1.6.4.tar.gz Running virtualenv-1.6.4/setup.py -q bdist_egg --dist-dir /tmp/easy_install- qWaoju/virtualenv-1.6.4/egg-dist-tmp-yFJeF5 warning: no previously-included files matching '*.*' found under directory 'docs/_templates' Adding virtualenv 1.6.4 to easy-install.pth file Installing virtualenv script to /usr/local/bin Installed /usr/local/lib/python2.7/dist-packages/virtualenv-1.6.4-py2.7.egg Processing dependencies for virtualenv Finished processing dependencies for virtualenv sudo bzr init-repo . Shared repository with trees (format: 2a) Location: shared repository: . sudo bzr branch lp:openstack-dashboard -r 46 /opt/osdb cd /opt/osdb sudo sh run_tests.sh cd openstack-dashboard cat /home/nova/creds/novarc sudo nano /opt/osdb/openstack-dashboard/local/local_settings.py sudo tools/with_venv.sh dashboard/manage.py syncdb sudo tools/with_venv.sh dashboard/manage.py runserver 0.0.0.0:8000 輸入 http://IP:8000 這樣我們就完成了一個具備 Dashboard (Web interface )的 Nova 控制中心,這個控制中心具有nova-compute功能但這樣無法表現openstack最大的優勢,彈性擴張計算能力 接著我們建立其他的node(nova-compute),讓整理系統擴大,您可以以此方法建立更多的節點 請繼續第二篇說明 有就是圖一nova-1電腦 ---- 第二篇 接著我們必須一樣先設定好網路環境與NTPServer 目標:設定網路環境 指令: sudo apt-get install bridge-utils 檢查 :dpkg -l | grep bridge-utils 成功結果 :ii bridge-utils 1.4-5ubuntu2 Utilities for configuring the Linux Ethernet bridge 錯誤狀況/故障排除:網路可能不通 或者 apt-get 因網路環境無法更新 指令: sudo vi /etc/network/interfaces 編輯ok 重啟 sudo /etc/init.d/networking restart auto lo iface lo inet loopback auto br100 iface br100 inet static bridge_ports eth0 bridge_stp off bridge_maxwait 0 bridge_fd 0 address 192.168.0.2 netmask 255.255.255.0 auto eth0 iface eth0 inet static address 172.18.104.12 netmask 255.255.255.0 broadcast 172.18.104.255 gateway 172.18.104.254 nameservers 61.64.127.1 檢查 :ifconfig 成功結果 : br100 Link encap:Ethernet HWaddr 00:21:5e:01:02:33 inet addr:192.168.0.2 Bcast:192.168.0.255 Mask:255.255.255.0 inet6 addr: fe80::221:5eff:fe01:233/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:189 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 B) TX bytes:18749 (18.7 KB) eth0 Link encap:Ethernet HWaddr 00:10:18:1a:48:15 inet addr:172.18.104.12 Bcast:172.18.104.255 Mask:255.255.255.0 inet6 addr: fe80::210:18ff:fe1a:4813/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:6470 errors:0 dropped:0 overruns:0 frame:0 TX packets:473 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:690979 (690.9 KB) TX bytes:108272 (108.2 KB) Interrupt:16 eth1 Link encap:Ethernet HWaddr 00:21:5e:01:02:33 inet6 addr: fe80::221:5eff:fe02:233/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:98 errors:0 dropped:0 overruns:0 frame:0 TX packets:148 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:8820 (8.8 KB) TX bytes:17781 (17.7 KB) Interrupt:17 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:4 errors:0 dropped:0 overruns:0 frame:0 TX packets:4 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:240 (240.0 B) TX bytes:240 (240.0 B) 錯誤狀況/故障排除: 失敗 networking 是無法 restart 大概就是編輯錯誤 安裝NTP Server Nova的各個所有組件的OpenStack要同步。 我們需要運做 NTPServer將每個組件同步時間 指令: sudo apt-get install ntp 檢查 :dpkg -l | grep ntp 成功結果 : ii ntp 1:4.2.6.p2+dfsg-1ubuntu5.1 Network Time Protocol daemon and utility programs ii ntpdate 1:4.2.6.p2+dfsg-1ubuntu5.1 client for setting system time from NTP server s 錯誤狀況/故障排除:網路可能不通 或者 apt-get 因網路環境無法更新 安裝完成後接著我們必須編輯 sudo vi /etc/ntp.conf 將底下這行加入後存檔 server 172.18.104.11 #NTP Server nova 控制中心的ip 然後我們將 NTP Server 重新啟動 * Stopping NTP server ntpd [ OK ] * Starting NTP server ntpd [ OK ] 安裝nova 元件 目標:安裝 Nova Components 指令: sudo apt-get install -y nova-common python-nova nova-compute vlan euca2ools unzip 設定nova 環境 sudo vi /etc/nova/nova.conf(這裡我們可以把剛剛設好的 nova-cc 的內容複製過來 改一下綠色的部分即可) --dhcpbridge_flagfile=/etc/nova/nova.conf --dhcpbridge=/usr/bin/nova-dhcpbridge --logdir=/var/log/nova --state_path=/var/lib/nova --lock_path=/var/lock/nova --verbose --s3_host=172.18.104.11 ###外部ip --rabbit_host=192.168.0.1 ###內部ip --cc_host=192.168.0.1 ###內部ip --ec2_url=http://172.18.104.11:8773/services/Cloud ###外部ip --fixed_range=10.0.0.0/8 --network_size=256 --FAKE_subdomain=ec2 --routing_source_ip=192.168.0.2 ###內部ip -------- 把routing source 改成這個節的的內部網路IP --sql_connection=mysql://root:nova@172.18.104.11/nova ###外部ip 需要mysql帳號:密碼 --glance_host=192.168.0.1 ###內部ip --image_service=nova.image.glance.GlanceImageService --iscsi_ip_prefix=192.168.0. 這樣就完成一個node 非常的簡單 安裝過程大部分較困難的地方為 nova 控制中心 因為我們這裡採用All in one方式,簡化了許多各個元件溝通與透過兩張網卡方式減少許多繁瑣的地方方便玩成實際測試環境的過程,不過若真正要真正達成以此營運的目的建議還是最好把nova-network nova-volume nova-objectstore nova-scheduler nova-compute nova-glance 各自分開,當某一個元件失效不至於造成全系統不能運作